<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,minimum-scale=1.0 user-scalable=no">
		<title>博瑞医检(诊所端)</title>
		<meta http-equiv="expires" content="0">
		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<link rel="stylesheet" href="../../css/reset.css" />
		<link rel="stylesheet" href="../../css/mui.min.css" />
		<link rel="stylesheet" href="../../css/iconfont.css" />
		<link rel="stylesheet" href="../../css/cmms.css" />
		<link rel="stylesheet" href="../../css/sale/index.css" />
		<link rel="stylesheet" href="../../css/doctor/index.css" />
		<script src="../../js/vconsole.min.js"></script>
	</head>
	<body>
		<div class="mui-content iphonex" id="index" v-cloak>
		    <nav class="mui-bar mui-bar-tab1">
				<a class="mui-tab-item1 mui-active1" data-page="index">
					<span class="mui-icon iconfont icon-home"></span>
					<span class="mui-tab-label1">首页</span>
				</a>
				<a class="mui-tab-item1" data-page="mine">
					<span class="mui-icon iconfont icon-wode">
						<!--<span class="mui-badge">2</span>-->
					</span>
					<span class="mui-tab-label1">我的</span>
				</a>
				
			</nav>
			<!--预约-->
			<div class="pre-btn" @tap="bespeak">
				<img src="../../img/pre-btn.png"/>
			</div>
		<div id="tabbar" class="mui-control-content mui-active">
			<div class="addr overflow">
				<i class="iconfont icon-dizhi left"></i>
				<span class="addr-detail left">{{totalData.hospitalName}}-{{totalData.userName}}</span>
				<span class="right">{{today}}</span>
			</div>
			<div class="showPanel">
		    	<div class="overflow panelContainer">
		    		<div class="center">
		    			<div class="center num">{{totalData.amounts}}</div>
		    			<div class="center todayCheck">今日检验金额(元)</div>
		    		</div>
		    	</div>
		    </div>
		    <div class="overflow panelContainer1">
		    		<div class="left">
		    			<div class="center num">{{totalData.commissionAmounts}}</div>
		    			<div class="center todayCheck">今日收入(元)</div>
		    		</div>
		    		<div class="right">
		    			<div class="center num">{{totalData.patientTotals}}</div>
		    			<div class="center todayCheck">今日检验人数</div>
		    		</div>
		    </div>
		    <div class="scan center">
		    	<div>快速查询:</div>
		    	<div><input type="number" placeholder="请扫描或输入条形码查询报告" v-model="inputCode" @focus="inputBarcode" @blur="outputBarcode"/></div>
		    	<div><span><i @tap="scanBarcode" class="iconfont icon-saomiao" :class="{'hidden':!isSearch}"></i></span><span class="btn-primary" :class="{'hidden':isSearch}" @tap="search">查询</span></div>
		    </div>
		    <div class="workDesk">
		    	我的工作台
		    </div>
		    <ul class="mui-table-view mui-grid-view mui-grid-9">
		    	<li v-for="menu in menuList" @tap="toDetail(menu.h)"  class="mui-table-view-cell mui-media mui-col-xs-4 mui-col-sm-3 orderTip">
		        	<a>
		        		<span class="mui-badge" v-if="orderTip>0&&menu.n=='支付'">{{orderTip}}</span>
			            <span><img :src="menu.i"/></span>
			            <!--<span><img src="../../img/single.png"/></span>-->
			            <div class="mui-media-body">{{menu.n}}</div>
		        	</a>
		       </li>
		    </ul> 
			</div>
			
		</div>
		<script src="../../js/mui.min.js"></script>
		<script src="https://res.wx.qq.com/open/js/jweixin-1.2.0.js"></script>
		<script src="../../js/vue.js"></script>
		<script src="../../js/cmms.js?time=333"></script>
		<script>
			new Vue({
				el:"#index",
				data:{
					today:'',
					totalData:'',//基本信息数据
					inputCode:'',
					hospitalList:'',
					isSearch:true,
					orderId:'',
					num:0,
					menuList:[],
					orderTip:0
				},
				mounted(){
					AT.muiAjaxDoctor('/partner-sale/partnerSale/wxConfig','post',{url:location.href.split('#')[0]},function(res){
						wx.config({
							appId:res.appId,
							timestamp:res.timestamp,
							nonceStr:res.nonceStr,
							signature:res.signature,
							jsApiList:['scanQRCode']
						});
					});
//					var vConsole = new VConsole();
					this.init();
					this.muiInit();
					
				},
				methods:{
					muiInit(){
						let _this = this;
						mui(".mui-bar-tab1").on('tap','.mui-tab-item1',function(){
							let page = this.getAttribute('data-page');
							if(page=='bespeak'){
								location.href = "./bespeak/bespeak.html"
							}
							if(page=='mine'){
								location.href = "./mine/mine.html"
							}
						})
					},
					getStatistics:function(){
						let _this = this;
					},
					toDetail(url){
						location.href = url;
					},
					bespeak(){
						//用于区别漫游登录，true漫游，false不漫游
						let flag = localStorage.getItem('roamFlag');
						console.log(flag);
						if(flag=='true'){
							mui.alert('您无权限操作！');
						}else{
							location.href = "../doctor/bespeak/bespeak.html";
						}
						
					},
					tocheckDetail:function(){
						location.href = this.checkDetail;
					},
					init:function(){
						let _this = this;
						AT.muiAjaxDoctor('/passport/getLoginUser','post',{},function(res){
							_this.menuList = res.menus;
							console.log(_this.menuList);
						});
						AT.muiAjaxDoctor('/clinic-doctor/statistics/home','post',{},
							function(res){
							console.log(res)
							_this.totalData = res;
							localStorage.setItem('userID',res.userId)
							_this.today = res.time.split('T')[0];
						});
						AT.muiAjaxDoctor('/clinic-doctor/order/getCountByUncharged','post',{},
							function(res){
								console.log(res);
								_this.num = res;
							}
						);
						AT.muiAjaxDoctor('/clinic-doctor/order/getOrderByUncharged','post',{},
							function(res){
								console.log(res);
								_this.orderTip = res.length;
							}
						)
						
					},
					/*点击按钮查询*/
					search(){
						let _this = this;
						let reg=/^[A-Za-z0-9]{10,12}$/;
						
						if(!reg.test(_this.inputCode)){
							mui.alert('条码必须为10~12位字母、数字!');
						}else{
							AT.muiAjaxDoctor('/clinic-doctor/order/getOrderByServiceCode','post',{
								specimenBarCode:_this.inputCode
							},function(realData){
								console.log(realData);
								if(realData=="false"){
									mui.alert('该条码未存在，请重新输入!');
								}else{
									_this.orderId = realData;
									location.href = "./orderDetail.html?id="+_this.orderId;
								}
							});
						}
					},
					//输入10-12位服务码
					inputBarcode:function(){
						let _this = this;
						_this.isSearch = false;
					},
					outputBarcode:function(){
						let _this = this;
						_this.isSearch = true;
					},
					//扫描14位服务码
					scanBarcode:function(){
						let _this = this;
						wx.scanQRCode({
							needResult: 1, // 默认为0，扫描结果由微信处理，1则直接返回扫描结果，
							scanType: ["barCode"], // 可以指定扫二维码还是一维码，默认二者都有
							success: function (res) {
								AT.muiAjaxDoctor('/clinic-doctor/order/getOrderByServiceCode','post',{
									specimenBarCode:_this.inputCode
								},function(realdata){
									console.log(realdata);
									if(realData=="false"){
										mui.alert('该条码未存在，请重新输入!');
									}else{
										_this.orderId = realData;
										location.href = "./orderDetail.html?id="+_this.orderId;
									}
								});
								
							}
						});
					}
				}
			})
		</script>
	</body>
</html>
